import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import './assets/font/iconfont.css'

import axios from 'axios'
//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'


//设置一个拦截器添加请求头
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

//配置请求超时时间为6秒
axios.defaults.timeout = 3000
//配置请求模板
axios.interceptors.response.use(
  response => {
    return response;
  },
  error => {
    if(error.message.includes('timeout')) {
      console.log("timeout!");
    }
  }
)


//把axios这个包挂载到原型对象上
Vue.prototype.$http = axios


Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
